#include "PeaShooter.h"
#include "stdio.h"

PeaShooter* PeaShooter::create()
{
	const CCRect RECT_SIZE_64 = CCRect::CCRect(0,0,64,64);

	char* imgUri = "images\\Plants\\Peashooter\\Peashooter0.png";
	PeaShooter* peashooter = new PeaShooter();
	peashooter->initWithSpriteFrame(CCSpriteFrame::create(imgUri,RECT_SIZE_64));
	peashooter->autorelease();

	unsigned int PEA_SHOOTER_FRAME_COUNT = 13;

	CCArray* animFrames = CCArray::createWithCapacity(PEA_SHOOTER_FRAME_COUNT);
	for (unsigned int i=0;i<PEA_SHOOTER_FRAME_COUNT;i++)
	{
		char* filename = new char[50];
		sprintf(filename,"images\\Plants\\Peashooter\\Peashooter%d.png",i);
		animFrames->addObject(CCSpriteFrame::create(filename,RECT_SIZE_64));
	}

	CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.3f);
	peashooter->runAction(CCRepeatForever::create( CCAnimate::create(animation) ) );

	return peashooter;
}
